import { BasicColumn, FormProps, FormSchema } from '/@/components/Table';
import { CODE, MEMO, NAME, SORT } from '/@/constant/dictionaryConstant';
import { CREATOR_NAME, CREATED_TIME } from '/@/constant';
import { id } from '/@/model/commonData';

export const dictionaryColumns: BasicColumn[] = [
  {
    title: CODE,
    dataIndex: 'code',
  },
  {
    title: NAME,
    dataIndex: 'name',
  },
  {
    title: MEMO,
    dataIndex: 'memo',
  },
  {
    title: CREATOR_NAME,
    dataIndex: 'creatorName',
  },
  {
    title: CREATED_TIME,
    dataIndex: 'createdTime',
  },
];

export function getDictionaryFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 100,
    schemas: [
      {
        field: 'code',
        label: CODE,
        component: 'Input',
        componentProps: {},
        colProps: {
          xl: 12,
          xxl: 8,
        },
      },
      {
        field: 'name',
        label: NAME,
        component: 'Input',
        componentProps: {},
        colProps: {
          xl: 12,
          xxl: 8,
        },
      },
    ],
  };
}

export const saveDictionaryFormSchemas: FormSchema[] = [
  {
    field: 'code',
    component: 'Input',
    label: CODE,
    required: true,
    componentProps: {},
  },
  {
    field: 'name',
    component: 'Input',
    label: NAME,
    required: true,
    componentProps: {},
  },
  {
    field: 'memo',
    component: 'InputTextArea',
    label: MEMO,
    componentProps: {
      autoSize: { minRows: 4, maxRows: 8 },
      allowClear: true,
      showCount: true,
      maxlength: 200,
    },
  },
  id,
];

export const saveDictionaryItemFormSchemas: FormSchema[] = [
  {
    field: 'name',
    component: 'Input',
    label: NAME,
    required: true,
    componentProps: {},
  },
  {
    field: 'sort',
    component: 'InputNumber',
    label: SORT,
    required: true,
    componentProps: {},
  },
  {
    field: 'memo',
    component: 'InputTextArea',
    label: MEMO,
    componentProps: {
      autoSize: { minRows: 4, maxRows: 8 },
      allowClear: true,
      showCount: true,
      maxlength: 200,
    },
  },
  id,
];

export const dictionaryItemColumns: BasicColumn[] = [
  {
    title: NAME,
    dataIndex: 'name',
  },
  {
    title: SORT,
    dataIndex: 'sort',
  },
  {
    title: MEMO,
    dataIndex: 'memo',
  },
  {
    title: CREATOR_NAME,
    dataIndex: 'creatorName',
  },
  {
    title: CREATED_TIME,
    dataIndex: 'createdTime',
  },
];
